<!-- $Id: goods_list.htm 17126 2010-04-23 10:30:26Z liuhui $ -->

<?php if ($this->_var['full_page']): ?>
<?php echo $this->fetch('pageheader.htm'); ?>
<?php echo $this->smarty_insert_scripts(array('files'=>'../js/utils.js,listtable.js')); ?>
<?php echo $this->fetch('goods_search_trans.htm'); ?>
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
<?php endif; ?>
<div align="center">
<?php echo $this->_var['next_sku']; ?>
</div>
<table cellpadding="3" cellspacing="1">
  <tr>
    
    <th><?php echo $this->_var['lang']['image']; ?></th>
    <th><a href="javascript:listTable.sort('goods_name'); "><?php echo $this->_var['lang']['goods_name']; ?></a><?php echo $this->_var['sort_goods_name']; ?></th>
    <th><a href="javascript:listTable.sort('goods_sn'); "><?php echo $this->_var['lang']['goods_sn']; ?></a><?php echo $this->_var['sort_goods_sn']; ?></th>
    <th><a href="javascript:listTable.sort('shop_price'); "><?php echo $this->_var['lang']['shop_price']; ?></a><?php echo $this->_var['sort_shop_price']; ?></th>
    <th><a href="javascript:listTable.sort('is_on_sale'); "><?php echo $this->_var['lang']['is_on_sale']; ?></a><?php echo $this->_var['sort_is_on_sale']; ?></th>

    <th><a href="javascript:listTable.sort('sort_order'); "><?php echo $this->_var['lang']['sort_order']; ?></a><?php echo $this->_var['sort_sort_order']; ?></th>
   
	 <th>语种</th>
	 <th>翻译</th>
	
   
  <tr>
  <?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['goods']):
?>
  <tr>
    
    <td class="first-cell"  align="center">
		<img src="../<?php echo $this->_var['goods']['thumbnail']; ?>" width="100" height="80" align="center">
	
	</td>
    <td class="first-cell" ><?php echo htmlspecialchars($this->_var['goods']['name']); ?></td>
    <td><?php echo $this->_var['goods']['sku']; ?></td>
    <td align="right"><?php echo $this->_var['goods']['price']; ?>

    </td>
    <td align="center"><img src="images/<?php if ($this->_var['goods']['status']): ?>yes<?php else: ?>no<?php endif; ?>.gif"  /></td>
  
    <td align="center"><span onclick="listTable.edit(this, 'edit_sort_order', <?php echo $this->_var['goods']['sku']; ?>)"><?php echo $this->_var['goods']['sort_order']; ?></span></td>
  	<td align="center"><?php echo $this->_var['lang_set'][$this->_var['goods']['store']]; ?></td>
	
	 <td align="center">
			<span id="trans_status_<?php echo $this->_var['key']; ?>">
				<?php if ($this->_var['goods']['is_trans']): ?><img src="images/yes.gif" /><?php else: ?><a href="javascript:;" onclick="single_trans('<?php echo $this->_var['key']; ?>');return false;"><img src="images/no.gif" border="0" /></a><?php endif; ?>
				
			</span>	&nbsp;
			<script  id="js_<?php echo $this->_var['key']; ?>" type="text/javascript"  translink="goods_trans.php?act=batch&type=auto_translate&sku=<?php echo $this->_var['goods']['sku']; ?>&run=<?php echo $this->_var['key']; ?>&store=<?php echo $this->_var['goods']['store']; ?>" ></script>
			<script language="javascript" type="text/javascript">var js_id_<?php echo $this->_var['key']; ?> = "<?php echo $this->_var['goods']['sku']; ?>";</script>
	
	</td>
	
	
  
	
  </tr>
  <?php endforeach; else: ?>
  <tr><td class="no-records" colspan="11"><?php echo $this->_var['lang']['no_records']; ?></td></tr>
  <?php endif; unset($_from); ?><?php $this->pop_vars();; ?>
</table>
<!-- end goods list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    <?php echo $this->fetch('page.htm'); ?>
    </td>
  </tr>
</table>

<?php if ($this->_var['full_page']): ?>
</div>

<div align="center">
  <input type="hidden" name="act" value="batch" />
  <select name="target_cat" style="display:none">
    <option value="0"><?php echo $this->_var['lang']['select_please']; ?></option><?php echo $this->_var['cat_list']; ?>
  </select>
	<?php if ($this->_var['suppliers_list'] > 0): ?>
  <!--二级主菜单：转移供货商-->
  <select name="suppliers_id" style="display:none">
    <option value="-1"><?php echo $this->_var['lang']['select_please']; ?></option>
    <option value="0"><?php echo $this->_var['lang']['lab_to_shopex']; ?></option>
    <?php $_from = $this->_var['suppliers_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'sl');$this->_foreach['sln'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['sln']['total'] > 0):
    foreach ($_from AS $this->_var['sl']):
        $this->_foreach['sln']['iteration']++;
?>
      <option value="<?php echo $this->_var['sl']['suppliers_id']; ?>"><?php echo $this->_var['sl']['suppliers_name']; ?></option>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
  </select>
  <!--end!-->
	<?php endif; ?>  
  <?php if ($this->_var['code'] != 'real_goods'): ?>
  <input type="hidden" name="extension_code" value="<?php echo $this->_var['code']; ?>" />
  <?php endif; ?>
  
  <input type="button" name="auto_translate" value="开始翻译" onclick="run=0;next_trans();" style="display:;"  />
   &nbsp;&nbsp;  
  <input type="button" name="Deploy Ok" value="清除不可翻译数据"  onclick="if(confirm('清除不可翻译数据')) location.href='goods_trans.php?act=del_trans_failed';"   />
  
  &nbsp;&nbsp;  
  <input type="button" name="Deploy Ok" value="清空"  onclick="if(confirm('确定清空数据')) location.href='goods_trans.php?act=deploy_empty';"   />

</div>
</form>

<script type="text/javascript">
  
	var run=0;	
	function next_trans(){		
		var ps = jQuery('#trans_status_'+run).position();
		document.body.scrollTop = parseInt(ps.top)-180;		
		var obj = document.getElementById('js_'+run);				
		if(obj!=undefined) {	
			document.getElementById('trans_status_'+run).innerHTML='<img src="images/loader.gif" />';		
			obj.src  = obj.getAttribute('translink')+'&rnd='+Math.random();		
					
		}	
				
		run++;
		
	}
	

	function resetrun(){
		run = 0;
		clearTimeout(setTimeout(function(){next_trans();},4000)-1);		
	}
	
	
	function single_trans(run_key){
		try{
			
			document.getElementById('trans_status_'+run_key).innerHTML='<img src="images/loader.gif" />';		
			var obj = document.getElementById('js_'+run_key);	
			var url  = obj.getAttribute('translink').replace('type=auto_translate','type=single_translate');
			obj.src = url+'&rnd='+Math.random();					
		}catch(e){
			alert(e.description);
		}		
		
	}
 
	

</script>

<script type="text/javascript">
  listTable.recordCount = <?php echo $this->_var['record_count']; ?>;
  listTable.pageCount = <?php echo $this->_var['page_count']; ?>;

  <?php $_from = $this->_var['filter']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'item');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['item']):
?>
  listTable.filter.<?php echo $this->_var['key']; ?> = '<?php echo $this->_var['item']; ?>';
  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>

  
  onload = function()
  {
    startCheckOrder(); // 开始检查订单
    document.forms['listForm'].reset();
  }

  /**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'trash')
      {
          return confirm(batch_trash_confirm);
      }
      else if (frm.elements['type'].value == 'not_on_sale')
      {
          return confirm(batch_no_on_sale);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext && frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }

  function changeAction()
  {
      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';
			
			<?php if ($this->_var['suppliers_list'] > 0): ?>
      frm.elements['suppliers_id'].style.display = frm.elements['type'].value == 'suppliers_move_to' ? '' : 'none';
			<?php endif; ?>

      if (!document.getElementById('btnSubmit').disabled &&
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }

</script>
<?php echo $this->fetch('pagefooter.htm'); ?>
<?php endif; ?>